package com.arouter.demo.homemodule;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.arouter.demo.homemodule.databinding.FragmentHomeBinding;
import com.arouter.demo.homemodule.viewmodel.HomeVm;

/**
 * desc:
 * 2018-05-30 14:00
 */
public class HomeFragment extends Fragment {

    private FragmentHomeBinding binding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {

        binding = DataBindingUtil.inflate(inflater,
                R.layout.fragment_home, container, false);
        binding.setHomeVm(new HomeVm());
        return binding.getRoot();
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 999 && data != null) {
            Toast.makeText(getActivity(),
                    "resultCode is " + resultCode + ", data is " + data.getStringExtra("result"),
                    Toast.LENGTH_LONG).show();
        }


    }
}
